package org.dce.screencapturer.actions.objects;

import java.awt.event.ActionEvent;
import java.util.Iterator;
import java.util.Set;

import org.dce.screencapturer.objects.DrawingObject;
import org.dce.screencapturer.util.IconFactory;

@SuppressWarnings("serial")
public class AlignToBottomAction 
	extends MultipleSelectionAction {

	public AlignToBottomAction() {
		super("categories.selection", "actions.alignTextToBottom",IconFactory.getIcon("/images/align-bottom.png"));
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		Set<DrawingObject> objects = getSelection();
		
		Iterator<DrawingObject> iterator = objects.iterator();
		
		DrawingObject first = iterator.next();
		
		int bottom = first.getY()+first.getHeight();
		
		while (iterator.hasNext()){
			DrawingObject object = iterator.next();
			object.setLocation(object.getX(),bottom - object.getHeight());
		}
	}

}
